|
|
|
|
|
|
|
Listing 30.1 VBSFILES.HTMAccessing the File System in Internet Explorer 4.0 |
|
|
|
|
|
|
|
|
<HTML>
<HEAD>
<SCRIPT Language = "VBScript">
<!--OPTION EXPLICIT
Dim objfs 'FileSystemObject Object
Dim objfile 'File Object
Dim objTs 'TextStream Object
Dim sInfoFile 'Path to the info file
Dim sInfo 'Variable used to store information
'Create a reference to the local file system
Set objFs = CreateObject("Scripting.FileSystemObject")
'Determine path to file in the windows directory
sInfoFile = objFS.GetSpecialFolder(0) & "\LASTVISIT.TXT"
'If file exists then read a line of text
If objfs.FileExists(sInfoFile) Then
Set objfile = objfs.GetFile(sInfoFile)
Set objts = objfile.OpenAsTextStream(1) 'Reading = 1, Writing = 2
sInfo = objts.ReadLine()
objts.close
Else
sInfo = "You haven't visited this web site before!"
End If
'Write message to the browser window
Document.Write sInfo & "<BR>"
'Store new message in the file for next time
sInfo = "Your last visit was <B>" & Now & "</B>. Welcome back!"
Set objts = objfile.OpenAsTextStream(2) 'Reading = 1, Writing = 2
objts.WriteLine(sInfo)
objts.close
Set objfs = Nothing
-->
</SCRIPT>
</HEAD>
</HTML> |
|
|
|
|
|
|
|
|
Using VBScript in Internet Explorer |
|
|
|
|
|
|
|
|
The following sections describe how to use client-side VBScript in your Web pages. VBScript can also be used on the server, as discussed in Chapter 27. Although server-side VBScript can be browser independent, client-side VBScript requires that the user have Microsoft Internet Explorer. Currently, Netscape users cannot run VBScript code. Remember to keep your audience in mind when using VBScript. |
|
|
|
|
|